﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using System.Data;
using System.Web.UI;

/// <summary>
///CheckListSearchShow 的摘要说明
/// </summary>
public class CheckListSearchShow : BaseSearchShow
{
	public CheckListSearchShow()
	{
		//
		//TODO: 在此处添加构造函数逻辑
		//
	}

    protected override IEnumerable<System.Web.UI.Control> GetSearchContrls(ConfigColumns cCol)
    {
        Literal ctrl = new Literal();

        DataTable tab = DBFactory.GetConn().exeTable(cCol.SearchShowSqlText);
        string html = string.Empty;
        foreach (DataRow row in tab.Rows)
        {
            html += "<input type='checkbox' name='" + cCol.ColumnName + "_SearchShow' value='" + row[cCol.SearchShowBindValueField].ToString() + "'";
            if ((HttpContext.Current.Handler as Page).IsPostBack)
            {
                string postValue = HttpContext.Current.Request[cCol.ColumnName + "_SearchShow"];
                if (!string.IsNullOrEmpty(postValue))
                {
                    if (postValue.ToLower().Split(',').Contains(row[cCol.SearchShowBindValueField].ToString().ToLower()))
                    {
                        html += " checked ";
                    }
                }
            }
            html += " />" + row[cCol.SearchShowBindTextField].ToString() + "&nbsp;";
        }

        ctrl.Text = html;

        yield return ctrl;
    }
}
